package com.roger.mybatisplus.demo.config;

import com.roger.mybatisplus.demo.realm.MyRealm;
import org.apache.shiro.realm.jdbc.JdbcRealm;
import org.apache.shiro.web.mgt.DefaultWebSecurityManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.sql.DataSource;

@Configuration
public class ShiroConfig {

    @Bean
    public DefaultWebSecurityManager securityManager(MyRealm myRealm){
        DefaultWebSecurityManager securityManager = new DefaultWebSecurityManager();
        securityManager.setRealm(myRealm);
        return securityManager;
    }

    @Bean
    public MyRealm myRealm(){
        return new MyRealm();
    }

//    @Bean
//    public JdbcRealm jdbcRealm(DataSource dataSource){
//        JdbcRealm jdbcRealm = new JdbcRealm();
//
//        jdbcRealm.setDataSource(dataSource);
//
//        return jdbcRealm;
//    }
}
